package com.szzg10.thinking.chapter18;

import java.io.IOException;
import java.util.ArrayList;

import nu.xom.Builder;
import nu.xom.Document;
import nu.xom.Elements;
import nu.xom.ParsingException;
import nu.xom.ValidityException;

public class People extends ArrayList<Person> {

	public People(String fileName) throws ValidityException, ParsingException, IOException {
		Document document = new Builder().build(fileName);
		Elements elements = document.getRootElement().getChildElements();
		for(int i = 0; i < elements.size(); i++) {
			add(new Person(elements.get(i)));
		}
	}
	
	public static void main(String[] args) throws ValidityException, ParsingException, IOException {
		People people = new People(Person.FILE_XML);
		for(int i = 0; i < people.size(); i++) {
			Person person = (Person)people.get(i);
			System.out.println(person);
		}
	}
}
